var n = require("../../@babel/runtime/helpers/defineProperty"),
  t = require("../../res/www.a9a.cn.js"),
  a = getApp(),
  i = wx.getStorageSync("COOK_U");
Page({
  data: {
    ifonLoad: !1,
    iflogin: !1,
    cert_height: "320rpx",
    morebtn_ico: "",
    cert_morebtn_onoff: "off",
    div_login: !1,
    U: {
      grade: 1,
      grade_title: "会员等级",
      grade_C: "开通会员・会员特权",
      gznum: 0,
      loveb: 0,
      nickname: "请点击登录",
      dataflag_title: "完善资料",
      dataflag_C: ">90%可被推荐",
      photo_s: "../../res/img/photo_m.png",
      myinfobfb: 0,
      bfb_w: 50,
    },
    sign: { signflag: !1, loveBname: "爱豆" },
    mask_class: "alpha0_100",
    GZHshow: !1,
  },
  onLoad: function () {
    var n = this;
    a.get_config("_ZEAI").then(function (a) {
      t.set_tabbar(),
        n.setData({
          loveb: a.loveb,
          color: a.color,
          rgbcolor: t.c16_rgb(a.color),
        });
    }),
      a.get_openid().then(function (t) {
        a.chklogin().then(function (t) {
          t && n.setData({ iflogin: !0 });
        }),
          n.init();
      });
  },
  onShow: function () {
    var n = this,
      t = this;
    a.chklogin().then(function (a) {
      a && (t.setData({ iflogin: !0 }), n.init());
    });
  },
  init: function () {
    var n = this;
    (i = wx.getStorageSync("COOK_U")),
      t.empty(i.openid) ||
        a.ajax({
          url: "my.php?submitok=U",
          data: { openid: i.openid },
          success: function (a) {
            if (0 == a.flag)
              n.setData({
                U: {
                  grade: 1,
                  grade_title: "会员等级",
                  grade_C: "开通会员・会员特权",
                  gznum: 0,
                  loveb: 0,
                  nickname: "请点击登录",
                  dataflag_title: "完善资料",
                  dataflag_C: ">90%可被推荐",
                  photo_s: "../../res/img/photo_m.png",
                  myinfobfb: 0,
                  bfb_w: 50,
                },
              });
            else {
              n.setData({
                ifonLoad: !0,
                ifnav: a.ifnav,
                tg_navtitle: a.tg_navtitle,
                U: a.U,
                VU: a.VU,
                RZ: a.RZ,
                MB: a.MB,
                GZH: a.GZH,
              });
              var i = t.get_tabbar_index("my_msg");
              a.btmnewnum > 0
                ? wx.setTabBarBadge({ index: i, text: a.btmnewnum })
                : wx.removeTabBarBadge({ index: i });
            }
          },
        });
  },
  myloginFn: function () {
    this.data.iflogin || wx.navigateTo({ url: "../login/login" });
  },
  copyuidFn: function (n) {
    var a = n.currentTarget.dataset.uid;
    t.copy_text({ data: a });
  },
  singMaskFn: function () {
    this.setData(n({}, "sign.signflag", !1));
  },
  qdFn: function () {
    var o = this;
    this.data.iflogin
      ? (t.empty(o.data.MB) || a.openSetting(o.data.MB),
        (i = wx.getStorageSync("COOK_U")),
        a.ajax({
          url: "my.php",
          data: { submitok: "ajax_sign", openid: i.openid },
          success: function (t) {
            if (1 == t.flag) {
              var a,
                i = parseInt(o.data.U.loveb) + parseInt(t.sign.num);
              o.setData(
                (n((a = {}), "sign.signflag", !0),
                n(a, "sign.loveBname", t.sign.loveBname),
                n(a, "sign.num", t.sign.num),
                n(a, "U.signflag", 0),
                n(a, "U.loveb", i),
                a)
              );
            } else
              "nodata" == t.flag
                ? o.setData({ mask_class: "alpha0_100", div_data: !0 })
                : wx.showToast({ title: t.msg, icon: "none", mask: !0 });
          },
        }))
      : wx.navigateTo({ url: "../login/login" });
  },
  mask_closeFn: function (t) {
    var a = this,
      i = t.currentTarget.dataset.maskid;
    this.setData({ mask_class: "alpha100_0" }),
      setTimeout(function () {
        a.setData(n({}, i, !1));
      }, 400);
  },
  emptyFn: function () {},
  followFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "follow?t=1" })
      : wx.navigateTo({ url: "../login/login" });
  },
  lovebFn: function () {
    t.empty(this.data.MB) || a.openSetting(this.data.MB),
      this.data.iflogin
        ? wx.navigateTo({ url: "loveb" })
        : wx.navigateTo({ url: "../login/login" });
  },
  refreshFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "refresh" })
      : wx.navigateTo({ url: "../login/login" });
  },
  topFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "top" })
      : wx.navigateTo({ url: "../login/login" });
  },
  back: function () {
    this.setData({ div_login: !1 });
  },
  VUFn: function () {
    "blur" == this.data.VU.class
      ? this.vipFn()
      : this.data.iflogin
      ? wx.navigateTo({ url: "browse?t=1" })
      : wx.navigateTo({ url: "../login/login" });
  },
  browseFn2: function () {
    this.data.iflogin
      ? (t.empty(this.data.MB) || a.openSetting(this.data.MB),
        wx.navigateTo({ url: "browse?t=2" }))
      : wx.navigateTo({ url: "../login/login" });
  },
  getUserProfile: function () {
    var i = this,
      o = wx.getStorageSync("COOK_U");
    t.empty(o.flag) || t.empty(o.openid)
      ? wx.getUserProfile({
          desc: "用于完善会员资料",
          success: function (t) {
            wx.request({
              url: a.WWW + "/api/wxxcx/reg.php",
              data: {
                submitok: "getUserProfile",
                openid: o.openid,
                unionid: o.unionid,
                nickname: t.userInfo.nickName,
                avatarUrl: t.userInfo.avatarUrl,
              },
              success: function (t) {
                var a;
                1 == (t = t.data).flag
                  ? i.setData(
                      (n((a = { div_login: !1 }), "U.id", t.U.id),
                      n(a, "U.flag", t.U.flag),
                      n(a, "U.nickname", t.U.nickname),
                      n(a, "U.photo_s", t.U.photo_s),
                      a)
                    )
                  : wx.showModal({
                      content: t.msg,
                      confirmColor: i.data.color,
                      confirmText: "朕知道了",
                      showCancel: !1,
                      success: function (n) {},
                    });
              },
            });
          },
        })
      : wx.request({
          url: a.WWW + "/api/wxxcx/my.php?submitok=udata",
          data: { openid: o.openid },
          success: function (n) {
            (n = n.data), i.setData({ div_login: !1, udata: n.data.udata });
          },
          fail: function (n) {
            wx.showModal({ content: n, showCancel: !1 });
          },
        });
  },
  getPhoneNumber: function (n) {
    var t = this;
    wx.login({
      success: function (o) {
        wx.request({
          url: a.WWW + "/api/wxxcx/get_openid.php",
          data: { code: o.code },
          success: function (o) {
            (o = o.data),
              (i = wx.getStorageSync("COOK_U")),
              a.ajax({
                url: "get_mob.php",
                data: {
                  session_key: encodeURIComponent(o.U.session_key),
                  encryptedData: encodeURIComponent(n.detail.encryptedData),
                  iv: encodeURIComponent(n.detail.iv),
                  openid: i.openid,
                  unionid: i.unionid,
                },
                success: function (n) {
                  t.init(), t.setData({ div_login: !1, iflogin: !0 });
                },
              });
          },
        });
      },
    });
  },
  vipFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "../my_vip/my_vip" })
      : wx.navigateTo({ url: "../login/login" });
  },
  my_infoFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "../reg/reg" })
      : wx.navigateTo({ url: "../login/login" });
  },
  certmoreFn: function () {
    "off" == this.data.cert_morebtn_onoff
      ? this.setData({
          cert_morebtn_onoff: "on",
          morebtn_ico: "",
          cert_height: "480rpx",
        })
      : this.setData({
          cert_morebtn_onoff: "off",
          morebtn_ico: "",
          cert_height: "320rpx",
        });
  },
  certlistFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "cert" })
      : wx.navigateTo({ url: "../login/login" });
  },
  certoneFn: function (n) {
    t.empty(this.data.MB) || a.openSetting(this.data.MB);
    var i = n.currentTarget.dataset.f;
    this.data.iflogin
      ? wx.navigateTo({ url: "cert?f=" + i })
      : wx.navigateTo({ url: "../login/login" });
  },
  hnFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "hongniang" })
      : wx.navigateTo({ url: "../login/login" });
  },
  photoFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "photo" })
      : wx.navigateTo({ url: "../login/login" });
  },
  mateshowFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "mateshow" })
      : wx.navigateTo({ url: "../login/login" });
  },
  hhFn: function () {
    this.data.iflogin
      ? (t.empty(this.data.MB) || a.openSetting(this.data.MB),
        wx.navigateTo({ url: "hh?t=2" }))
      : wx.navigateTo({ url: "../login/login" });
  },
  kefuFn: function () {
    wx.navigateTo({ url: "../about/about" });
  },
  setFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "set" })
      : wx.navigateTo({ url: "../login/login" });
  },
  xqkFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "xqk?uid=" + this.data.U.id })
      : wx.navigateTo({ url: "../login/login" });
  },
  tgFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "../tg/my" })
      : wx.navigateTo({ url: "../login/login" });
  },
  signFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "sign" })
      : wx.navigateTo({ url: "../login/login" });
  },
  qxFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "hongniang?currentTab=1" })
      : wx.navigateTo({ url: "../login/login" });
  },
  yjFn: function () {
    this.data.iflogin
      ? wx.navigateTo({ url: "hongniang?currentTab=2" })
      : wx.navigateTo({ url: "../login/login" });
  },
  photo_bFn: function (n) {
    if (this.data.iflogin && t.ifint(this.data.U.id))
      2 == this.data.U.flag
        ? wx.navigateTo({ url: "../reg/reg" })
        : wx.navigateTo({ url: "../u/u?uid=" + this.data.U.id });
    else {
      var a = n.currentTarget.dataset.photo_b;
      t.empty(a) || wx.previewImage({ current: a, urls: [a] });
    }
  },
  gzfFn: function () {
    this.setData({ GZHshow: !0 });
  },
  kefu_closeFn: function () {
    this.setData({ GZHshow: !1 });
  },
  lawFn: function (n) {
    var t = n.currentTarget.dataset.kind;
    wx.navigateTo({ url: "/pages/about/law?kind=" + t });
  },
  onShareAppMessage: function () {
    return { imageUrl: "", title: "我的", path: "/pages/my/my" };
  },
  ifagreeFn: function (n) {
    1 == n.detail.value
      ? this.setData({ ifagree: !0 })
      : this.setData({ ifagree: !1 });
  },
  ifagree_passFn: function (n) {
    wx.showToast({
      title: "请先点击同意《用户协议》和《隐私条款》",
      icon: "none",
      mask: !0,
      duration: 3e3,
    });
  },
  privacy_agree: function (n) {
    console.log("agree");
  },
  privacy_disagree: function (n) {
    console.log("disagree"), wx.exitMiniProgram();
  },
});
